﻿using ExtensionMethods.Foo;
using static System.Console;
// using ExtensionMethods.Bar;   // importing both namespaces creates an ambiguous compiler error

namespace ExtensionMethods
{
    namespace Foo
    {
        public static class StringExtensions
        {
            //this关键字对string方法进行扩展
            public static int GetWordCount(this string s) =>
                s.Split().Length;
            
        }

    }

    class Program
    {
        static void Main()
        {
            string fox = "the quick brown fox jumped over the lazy dogs down 9876543210 times";
            int wordCount =     fox.GetWordCount();//GetWordCount()是字符串的扩展方法
            WriteLine($"{wordCount} words");
            ReadLine();
        }
    }
}
